import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;


class Student {

}
class IntCmp implements Comparator<Integer> {
    @Override
    public int compare(Integer o1, Integer o2) {
//        return o1.compareTo(o2);//o1(child)>o2(parent)时返回正值,是创建小根堆的逻辑
        return o2.compareTo(o1);//这是创建大根堆的逻辑
    }
}
public class Test {

    public static void main(String[] args) {
        int[] array={27,15,19,18,28,34,65,49,25,37};
        TestHeap testHeap=new TestHeap();
        testHeap.init(array);
        testHeap.createBigHeap();//自己创建的大根堆
        testHeap.heapSort();
    }

    public static void main6(String[] args) {
        TestHeap testHeap=new TestHeap();
        int[] array={27,15,19,18,28,34,65,49,25,37};
        int[] ret=testHeap.smallestK2(array,3);
        System.out.println(Arrays.toString(ret));
    }

    public static void main5(String[] args) {
        PriorityQueue<Integer> pq=new PriorityQueue<>(new IntCmp());
        pq.offer(10);
        pq.offer(2);
        pq.offer(3);
        System.out.println(pq.poll());
        System.out.println(pq.poll());
    }

    public static void main4(String[] args) {
        ArrayList<Integer> list=new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        PriorityQueue<Integer> pq=new PriorityQueue<>(list);
        System.out.println(pq.poll());
    }

    public static void main3(String[] args) {
        PriorityQueue<Student> priorityQueue = new PriorityQueue<>();
        priorityQueue.offer(new Student());
    }
    public static void main2(String[] args) {
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>();
        priorityQueue.offer(12);
        priorityQueue.offer(5);
        priorityQueue.offer(10);
        System.out.println(priorityQueue.peek());//默认是小根堆
        System.out.println(priorityQueue.poll());
        System.out.println(priorityQueue.poll());
    }
    public static void main1(String[] args) {
        int[] array={27,15,19,18,28,34,65,49,25,37};
        TestHeap testHeap=new TestHeap();
        testHeap.init(array);
        testHeap.createBigHeap();
//        testHeap.offer(80);
        testHeap.poll();
    }
}
